%梯度滤波
img=imread("img/img.jpg");
subplot(2,3,1),imshow(img),xlabel("原始图像");

img=double(img);
[Gx,Gy]=gradient(img);
G=sqrt(Gx.*Gx+Gy.*Gy);

img1=G;
subplot(2,3,2),imshow(uint8(img1)),xlabel("梯度法滤波图像");


img2=img;
K=find(G>=7);
img2(K)=G(K);
subplot(2,3,3),imshow(uint8(img2)),xlabel("第一种情况的滤波图像");

img3=img;
K=find(G>=7);
img3(K)=255;
subplot(2,3,4),imshow(uint8(img3)),xlabel("第二种情况的滤波图像");

img4=G;
K=find(G<=7);
img4(K)=255;
subplot(2,3,5),imshow(uint8(img4)),xlabel("第三种情况的滤波图像");

img5=img;
K=find(G<=7);
img5(K)=0;
Q=find(G>=7);
img5(Q)=255;
subplot(2,3,6),imshow(uint8(img5)),xlabel("第四种情况的滤波图像");